import {reactive,onMounted,onBeforeUnmount} from 'vue'
export default function usePoint(){
    const point=reactive({
        x:0,
        y:0
    })
    const setPoint=(e:MouseEvent)=>{
        point.x=e.clientX
        point.y=e.clientY
    }
    onMounted(()=>{
        //进行事件绑定
        document.addEventListener('mousemove',setPoint)
    })
    onBeforeUnmount(()=>{
        //解绑事件
        document.removeEventListener('mousemove',setPoint)
    })
    return point
}